<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="/css/admin.css" rel="stylesheet" type="text/css" />
<script src="/js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="/js/ckfinder/ckfinder.js" type="text/javascript"></script>
<style type="text/css">
	.longtxt{width:300px;}
	.handimg{cursor:pointer;}
	#div_contentlink{ margin-top:5px;}
	#div_contentlink a, #div_contentlink a:visited{ padding:5px 10px;}
	a.on ,#div_contentlink a.on:visited{ background-color:#E5ECF9;-moz-border-radius-topleft: 3px;
	-khtml-border-top-left-radius: 3px;
	-webkit-border-top-left-radius: 3px;
	border-top-left-radius: 3px;
	-moz-border-radius-topright: 3px;
	-khtml-border-top-right-radius: 3px;
	-webkit-border-top-right-radius: 3px;
	border-top-right-radius: 3px;}
	#div_dong{width:99%; padding:5px;background-color:#E5ECF9; }
	#div_jing{width:99%; padding:5px;background-color:#E5ECF9;}
	textarea{width:99%;height:450px;}
</style>
<script type="text/javascript">
	$(function () {	
		var thumburl = '<?=$thumbs?>';
		if(thumburl != ''){
			thumburl = thumburl.replace("/images/","/_thumbs/images/");
			$("#preview").html("<img src='" + thumburl + "' />");
			$("#preview").css('display','');
		}

		$("#ttype").val('<?=$ttype?>');

		$("#scontent").css('display','none');
	});				

	function VerifyPage(){
		if($("#tname").val() == ''){
			alert('模板名称不能为空!');
			return false;
		}
		return true;
	}

	function MyGoBack(){ 
		window.location = "/cms/templates";		
	}

	function BrowseServer( ){		
		var finder = new CKFinder();
		//finder.startupPath = 'Images:/';		
		finder.selectActionFunction = SetFileField;
		//finder.selectActionData = 'titlethumbs';		
		//finder.selectThumbnailActionFunction = MyShowThumbnails;
		finder.popup();
	}

	function SetFileField( fileUrl ){
		//var sFileName = this.getSelectedFile().name;
		$("#thumbs").val(fileUrl);		
		var thumburl = fileUrl.replace("/images/","/_thumbs/images/");//fileUrl;//
		$("#preview").html('<img src="' + thumburl + '" />');
		$("#preview").css('display','');
	}

	function clearTitlethumb(){
		$("#thumbs").val('');
		$("#preview").html('');
		$("#preview").css('display','none');
	}

	function toggleContent(){
		$("#tcontent").toggle();
		$("#scontent").toggle();
		
		$("#linkdong").toggleClass('on');
		$("#linkjing").toggleClass('on');		
	}
	
</script>
</head>
<body>
<form name="form1" action="/cms/savetpl" method="post" onSubmit="return VerifyPage();">
<input type="hidden" name="tid" value="<?=$tid ?>" />
<div class="listTitle">编辑模板</div>
<div>
<table cellpadding="3" width="100%">
<tr><td>类型</td><td colspan="3"><select id="ttype" name="ttype"><option value="0">首页</option><option value="1">栏目</option><option value="2">文档</option><option value="3">公共</option></select></td></tr>
<tr><td width="60" nowrap>名称</td><td><input type="text" class="longtxt" id="tname" name="tname" value="<?=$tname?>" /></td><td>描述</td><td><input type="text" class="longtxt" id="descr" name="descr" value="<?=$descr?>" /></td></tr>
<tr><td>内容</td><td colspan="3">
<div id="div_contentlink"><a id="linkdong" href="javascript:toggleContent()" class="on">动态内容</a><a href="javascript:toggleContent()" id="linkjing" class="">静态内容</a></div>
<div id="div_dong"><textarea id="tcontent" name="tcontent" rows="20" cols="5" ><?=$tcontent?></textarea><textarea id="scontent" name="scontent" rows="20" cols="5" ><?=$scontent?></textarea></div>
</td>
</tr>
<tr><td>缩略图</td><td valign="middle" colspan="3"><span id="preview" style="display:none;"></span><a href="javascript:BrowseServer();">添加</a>&nbsp;&nbsp;<a href="javascript:clearTitlethumb()">清除</a><input type="hidden" id="thumbs" name="thumbs" value="<?=$thumbs?>" /></td></tr>
<tr><td></td><td colspan="3"><input type="submit" value=" 保存 " />&nbsp;&nbsp;<input type="button" value="返回" onclick="MyGoBack();" />&nbsp;&nbsp;<font color='#ff0000'><?=$tip?></font></td></tr>
</table>
</div>
</form>
</body>
</html>